/*
 * ConnectCommand handles the connect command that allows the users to manually request
 * to connect to Google Calendar server.
 */

/** @author A0105514U */

package logic;

import global.CommandType.Type;
import global.Constant;
import global.GCalThread;
import global.GlobalFields;
import global.InternetConnectionDetector;

import java.util.ArrayList;

public class ConnectCommand extends Command{
	public ConnectCommand(){
		super();
	}
	
	public ArrayList<String> execute() {
		InternetConnectionDetector detector = new InternetConnectionDetector();

		if(detector.detect() && !GlobalFields.IS_GOOGLE_CONNECTED){
			GlobalFields.IS_TO_CONNECT = true;
			GlobalFields.IS_FIRST_AUTH = false;
			GlobalFields.gcal = new GCalThread();
		}
		ExecutionHandler.setIsUndo(false);
        ExecutionHandler.setMostRecentCommandType(Type.CONNECT);
		
		ArrayList<String> feedback = new ArrayList<String>();
		feedback.add(Constant.GOOGLE_CONNECTED_MESSAGE);
		return feedback;
	}
	
	public String getTestFeedback() {
		return "connect";
	}
}